import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";
// 引入全局混入
import checkPermission from '@/mixin/checkPermission'
// 引入自定义指令
// import * as directives from '@/directives'
import * as directives from "@/directives";
// 引入过滤器的所有function
import * as Filters from "@/filters";
import "@/icons"; // icon
import "@/permission"; // permission control
// 组件全局注册
import Componentss from "@/components";
// 来一个全局时间过滤器
// Vue.filter('dateFormat',function(originVal){
//   const dt=new Date(originVal);
//   const y=dt.getFullYear();
//   const m=(dt.getMonth()+1+'').padStart(2,'0')
//   const d=(dt.getDate()+'').padStart(2,'0')

//   const hh=(dt.getHours()+'').padStart(2,'0')
//   const mm=(dt.getMinutes()+'').padStart(2,'0')
//   const ss=(dt.getSeconds()+'').padStart(2,'0')
//   return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
// })
/**
 * 来一个 组件的全局注册
 * */

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }
// 注册全局混入
Vue.mixin(checkPermission)
// set ElementUI lang to EN
Vue.use(ElementUI, { locale });
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
// 遍历每一个自定义指令 完成注册
// Object.keys(directives).forEach(key=>{
//   Vue.directive(key,directives[key])
// })
// 注册自定义指令
// 遍历所有的导出的指令对象 完成自定义全局注册
Object.keys(directives).forEach(key => {
  // 注册自定义指令
  Vue.directive(key, directives[key]);
});
// 注册全局的过滤器
Object.keys(Filters).forEach(key => {
  Vue.filter(key, Filters[key]);
});
Vue.config.productionTip = false;
Vue.use(Componentss);

new Vue({
  el: "#app",
  router,
  store,
  render: h => h(App)
});
